function LocalWaveletPowerSpectrum_tps(wave,period,scale,coi,power,sig95,global_ws,global_signif,vec,x,out)

% out=0 -> screen display
% out=1 -> print in a file

if out==1
    close all
end
figure
if out==1
    set(gcf,'Visible','off')
end
subplot('position',[0.1 0.75 0.65 0.2])
plot(x,vec)
set(gca,'XLim',[x(1) x(length(x))])
%xlabel('Time (units)')
ylabel('SST Anomalies - degC')
title('a) TMI')
tick_date_gc(x,-10,10)
hold off

%--- Contour plot wavelet power spectrum
subplot('position',[0.1 0.37 0.65 0.28])
levels = [0.0625,0.125,0.25,0.5,1,2,4,8,16,32,64,128,256,512] ;
Yticks = 2.^(fix(log2(min(period))):fix(log2(max(period))));
contourf(x,log2(period),log2(power),log2(levels));  %*** or use 'contourfill'
shading flat
%imagesc(x,log2(period),log2(power));  %*** uncomment for 'image' plot
%xlabel('Time')
ylabel('Period (days)')
title('b) Wavelet Power Spectrum')
set(gca,'XLim',[x(1) x(length(x))])
set(gca,'YLim',log2([min(period),(x(length(x))-x(1))]), ...
      'YDir','reverse', ...
      'YTick',log2(Yticks(:)), ...
      'YTickLabel',Yticks)
% 95% significance contour, levels at -99 (fake) and 1 (95% signif)
hold on
contour(x,log2(period),sig95,[-99,1],'k');
hold on
% cone-of-influence, anything "below" is dubious
plot(x,log2(coi),'k')
% Shading of Coi
dt=mean(diff(squeeze(x)));
tt=[x([1 1])-dt*.5,x,x([end end])+dt*.5];
hcoi=fill(tt,log2([period([end 1]) coi period([1 end])]),'w');
set(hcoi,'alphadatamapping','direct','facealpha',.5)
tick_date_gc_inverse(x,log2(min(period)),log2(x(length(x))-x(1)))
hold off

%--- Plot global wavelet spectrum
subplot('position',[0.77 0.37 0.2 0.28])
plot(global_ws,log2(period))
hold on
plot(global_signif,log2(period),'--')
hold off
         % xlabel('Power (degC^2)')
title('c) Global Wavelet Spectrum')
set(gca,'YLim',log2([min(period),(x(length(x))-x(1))]), ...
      'YDir','reverse', ...
      'YTick',log2(Yticks(:)), ...
      'YTickLabel','')
%set(gca,'XLim',[0,1.25*max(global_ws)])

if out==1
    print('-f1','-depsc2','./LWPS_tps.eps')
end



